package com.gitee.aurora.core.enums;

import java.util.Objects;

public enum OperateTypeEnums {
    notEmpty("非空", 0, "notEmpty","","字段不能为空"),
    prefixChar("前缀校验", 1, "prefixChar", "A","字段必须以{}开头"),
    charLength("字段长度校验",2,"charLength","23","字段长度必须是{}"),
    onlyChar("指定字符校验",3,"onlyChar","A/B/C","字段必须是指定字符{}");

    // 成员变量
    private String name;
    private int code;
    private String methodName;
    private String args;
    private String tip;

    // 构造方法
    OperateTypeEnums(String name, int code, String methodName, String args,String tip) {
        this.name = name;
        this.code = code;
        this.methodName = methodName;
        this.args = args;
        this.tip = tip;
    }

    // 普通方法
    public static String getName(int code) {
        for (OperateTypeEnums o : OperateTypeEnums.values()) {
            if (o.getCode() == code) {
                return o.name;
            }
        }
        return null;
    }

    // 普通方法
    public static String getArgs(String methodName) {
        for (OperateTypeEnums o : OperateTypeEnums.values()) {
            if (Objects.equals(o.getMethodName(), methodName)) {
                return o.args;
            }
        }
        return null;
    }

    public static String getTip(String methodName) {
        for (OperateTypeEnums o : OperateTypeEnums.values()) {
            if (Objects.equals(o.getMethodName(), methodName)) {
                return o.tip;
            }
        }
        return null;
    }

    public static String getMethodName(int code) {
        for (OperateTypeEnums o : OperateTypeEnums.values()) {
            if (o.getCode() == code) {
                return o.methodName;
            }
        }
        return null;
    }


    public void setName(String name) {
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getMethodName() {
       return methodName;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public String getArgs() {
        return args;
    }

    public void setArgs(String args) {
        this.args = args;
    }

    public String getTip() {
        return tip;
    }

    public void setTip(String tip) {
        this.tip = tip;
    }
}

